package com.hzf.booklibrary.api;

import com.hzf.booklibrary.base.Constant;
import com.hzf.booklibrary.bean.clazz.Clazz;
import com.hzf.booklibrary.bean.token.TokenBean;
import com.hzf.booklibrary.utils.LogUtils;

import okhttp3.OkHttpClient;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class TokenApi {

    public static TokenApi instance;

    private TokenApiService service;

    public TokenApi() {
        //联网请求
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(Constant.API_BASE_URL)
                // 添加Gson转换器
                .addConverterFactory(GsonConverterFactory.create())

                .build();

        service = retrofit.create(TokenApiService.class);

    }

    public static TokenApi getInstance() {
        if (instance == null)
            instance = new TokenApi();
        return instance;
    }

    public Call<TokenBean> getToken(String client_id, String client_secret) {
        return service.getToken(client_id, client_secret);
    }

    public Call<Clazz> getClazzInfo(String token,String deviceId){
        return service.getClazzInfo(token,deviceId);
    }
}
